package org.jeecg.modules.cascv.rabbitmq;

import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.amqp.core.Message;
/**
 * @author;作者
 * @Date 2023/6/2 9:55
 * @Description :
 * @Version
 */
@Component
@Slf4j
public class TofileListener {

    @RabbitListener(queues = "boot_queue")
    public void listenerQueue(Message message){
        // System.out.println(new String(message.getBody()));
        //log.info("接收数据");
        if (message == null) {
            log.error("RabbitMQ消息内容为空！");
            return;
        }

        String jsonStr = null;

        try {
            jsonStr = new String(message.getBody(), "utf-8");
          //  log.info("接收数据中==>"+jsonStr);
            FileUtil.appendUtf8String(jsonStr+ System.lineSeparator(),
                    "E:\\图像数据\\生命生态\\"+
                            "TPSR监视CCD1图像数据.txt");
        } catch (Exception e) {
            log.error("", e);
        }

    }

}
